<?php 
include('./fun.php');
$conn=my_sql($cfg);
$re=adm_login();
if($re['err']=='no_login'){no_login();}

$sql='select * from '.$cfg['e'].'help ';

$page=g('page');
if(!$page){$page=1;}
$page_num=20;$start=($page-1)*$page_num;
$sql.=' order by id desc limit '.$start.','.$page_num;

$l=db($sql);

?>
<style>

</style>
<hh><b>帮助文档中心</b></hh>
<mm>
<index>
<a class="m b" onclick="edit($(this))" i="0">新帮助文档</a>
</index>
</mm>

<?php 
if($l){
echo '<table>';
th(['分类','标题','标签','操作']);
foreach($l as $v){

echo '<tr>';
echo '<td>'.$v['c'].'</td>';
echo '<td>'.$v['title'].'</td>';
echo '<td>'.$v['tag'].'</td>';
echo '<td>
'.($v['state']==1?'<a onclick="state($(this))" i="'.$v['id'].'" val="stop">停用</a>':'<a class="select" onclick="del($(this))" i="'.$v['id'].'">删除</a><a onclick="state($(this))" i="'.$v['id'].'" val="1">上线</a>').'
<a onclick="edit($(this))" i="'.$v['id'].'">修改</a>
</td>';
echo '</tr>';
}

echo '</table>';
page();
}else{no_data();}

?>









<script>
function edit(o){
var id=o.attr('i');
right({title:'帮助文档编辑',url:'help_edit.php?id='+id,width:'1000px'})
}

function state(o){
var id=o.attr('i');if(!id){msg('请指定文档');return;}
val=o.attr('val');if(val!=1){val='stop';}
var data={state:val}
post('help_edit',data,id,function(res){
main_load();
});
}

function del(o){
var id=o.attr('i');if(!id){msg('请指定文档');return;}
if(!confirm("是否删除文档，删除将无法恢复，是否继续?")){return;}
post('help_del','',id,function(res){
    main_load();
});
}


</script>